package com.umerclass.ui.anmo.customer;

import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.umerclass.R;
import com.umerclass.bean.customer.TaoCanBean;
import com.umerclass.frame.model.InfoResult;
import com.umerclass.frame.ui.activity.BaseActivity;
import com.umerclass.frame.ui.recycleview.listener.OptListener;
import com.umerclass.ui.anmo.customer.adapter.CustomerHomeAdapter;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.OnClick;

public class CustomerHomeActivity extends BaseActivity implements OptListener {

    @BindView(R.id.linear_back)
    LinearLayout linearBack;
    @BindView(R.id.tv1)
    TextView tv1;
    @BindView(R.id.tv2)
    TextView tv2;
    @BindView(R.id.tv3)
    TextView tv3;
    @BindView(R.id.recycleview)
    RecyclerView recycleview;
    @BindView(R.id.tv4)
    TextView tv4;
    @BindView(R.id.tv_start)
    TextView tvStart;
    private CustomerHomeAdapter customerHomeAdapter;
    private List<TaoCanBean> info = new ArrayList<>();
    private LinearLayoutManager layoutManager;

    @Override
    public boolean isImmersionBarEnabled() {
        return false;
    }

    @Override
    public boolean isSupportSwipeBack() {
        return false;
    }

    @Override
    public int getLayoutResId() {
        return R.layout.activity_customer_home;
    }

    @Override
    public void init() {
        Window window = getWindow();
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.setStatusBarColor(getResources().getColor(R.color.white));
        todo();
        layoutManager = new LinearLayoutManager(this);
        layoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
        customerHomeAdapter = new CustomerHomeAdapter(this,
                info,R.layout.activity_customer_home_item,this);
        recycleview.setLayoutManager(layoutManager);
        recycleview.setAdapter(customerHomeAdapter);
    }

    @Override
    public void loadData() {

    }

    @OnClick({R.id.linear_back,R.id.tv3,R.id.tv_start})
    public void OnClick(View view) {
        switch (view.getId()) {
            case R.id.linear_back:
                finish();
                break;
            case R.id.tv3:
                switchTo(CustomerHomeActivity.this,ShopPayActivity.class,false);
                break;
            case R.id.tv_start:
                switchTo(CustomerHomeActivity.this,MyCountsActivity.class,false);
                break;
                default:break;
        }
    }

    @Override
    public void onOptClick(View view, Object object) {

    }

    @Override
    protected void onSuccess(int what, InfoResult t) {

    }

    @Override
    protected void onFail(int what, InfoResult t) {

    }

    private void todo(){
        TaoCanBean bean = new TaoCanBean();
        bean.setName("单次");
        bean.setPrice("23");
        bean.setTotalNum(3);

        TaoCanBean bean2 = new TaoCanBean();
        bean2.setName("套餐一");
        bean2.setPrice("23");
        bean2.setTotalNum(3);

        TaoCanBean bean3 = new TaoCanBean();
        bean3.setName("套餐一");
        bean3.setPrice("23");
        bean3.setTotalNum(3);

        TaoCanBean bean4 = new TaoCanBean();
        bean4.setName("套餐一");
        bean4.setPrice("23");
        bean4.setTotalNum(3);

        TaoCanBean bean5 = new TaoCanBean();
        bean5.setName("套餐一");
        bean5.setPrice("23");
        bean5.setTotalNum(3);

        info.add(bean);
        info.add(bean2);
        info.add(bean3);
        info.add(bean4);
        info.add(bean5);
    }
}
